<?php
/**
 * CustStockOutReturn
 */
class CSoR extends AppModel {
    var $name = 'CSoR';

    var $useTable = 'cust_stock_out_returns';

    const CUST_STOCK_IN_TYPE = 'R';

    var $belongsTo = array('Product', 'CustProductSite',
        'CSoRH' => array(
            'foreignKey' => 'cust_stock_out_return_head_id'
        ),
        'Unit' => array(
                'fields' => array('id', 'title')
        ),
    );

    var $hasMany = array(
        'ProductSerial' => array(
            'foreignKey' => 'cust_stock_in_id',
            'conditions' => array(
                'cust_stock_in_type' => self::CUST_STOCK_IN_TYPE
            )
        )
    );

    var $validate = array(
        'return_qty' => array('rule' => array('comparison', '>', 0), 'message' => 'Invalid Return qty.'),
    );
}
?>
